import javax.accessibility.AccessibleContext;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Objects;
import java.util.Random;

public class PartGenerator_JFrame extends JFrame {

    public PartGenerator_JFrame() {

        //初始化界面
        initJFrame();

        //初始化菜单
        initJmenu();

        //初始化圣遗物数值
        PartGenerator_Method pgm = new PartGenerator_Method();
        int k = pgm.NUMposition();
        String POSITION = pgm.position(k);//部位
        String MAINTERM = pgm.mainTerm(k);//生成主词条
        String[] strings = pgm.FourSecondaryTrem(k, MAINTERM);//生成四个副词条
        double[] seg = pgm.SecondaryEntryGear(k, MAINTERM, strings);//生成4个副词条的数值
        double[] LV20seg = pgm.LV20SecondaryEntryGear(strings, seg);//生成20级副词条数值


        ImageIcon icon = new ImageIcon("image/klee.png");
        JLabel jl = new JLabel(icon);
        jl.setBounds(29, 29, 377, 662);
        //this.add(jLabel);
        this.getContentPane().add(jl);

        JButton jbt = new JButton("暂停");
        jbt.setBounds(1000, 550, 100, 50);
        this.getContentPane().add(jbt);

        ImageIcon iconPosition = new ImageIcon("image/1.png");
        JLabel jl1 = new JLabel(iconPosition);
        jl1.setBounds(800, 150, 120, 120);
        this.getContentPane().add(jl1);

        JLabel firtrem = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        firtrem.setForeground(new Color(0, 0, 0));
        firtrem.setFont(new Font("", Font.BOLD, 30));
        firtrem.setText(POSITION);//圣遗物部位
        firtrem.setBounds(950, 100, 200, 120);
        this.getContentPane().add(firtrem);

        JLabel firtremNUM = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        firtremNUM.setForeground(new Color(0, 0, 0));
        firtremNUM.setFont(new Font("", Font.BOLD, 40));
        firtremNUM.setText(MAINTERM);//主词条类型
        firtremNUM.setBounds(950, 110, 400, 200);
        this.getContentPane().add(firtremNUM);

        JLabel plus20 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        plus20.setForeground(new Color(0, 0, 0));
        plus20.setFont(new Font("", Font.BOLD, 20));
        plus20.setText("+20");
        plus20.setBounds(950, 200, 200, 120);
        this.getContentPane().add(plus20);

        //右侧副词条的四个数值

        JLabel sectrem1 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem1.setForeground(new Color(0, 0, 0));
        sectrem1.setFont(new Font("", Font.BOLD, 30));
        sectrem1.setText(String.valueOf(strings[0] + LV20seg[0]));//副词条数值
        sectrem1.setBounds(950, 250 + (0 + 1) * 40, 250, 120);
        this.getContentPane().add(sectrem1);

        JLabel sectrem2 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem2.setForeground(new Color(0, 0, 0));
        sectrem2.setFont(new Font("", Font.BOLD, 30));
        sectrem2.setText(String.valueOf(strings[1] + LV20seg[1]));//副词条数值
        sectrem2.setBounds(950, 250 + (1 + 1) * 40, 250, 120);
        this.getContentPane().add(sectrem2);

        JLabel sectrem3 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem3.setForeground(new Color(0, 0, 0));
        sectrem3.setFont(new Font("", Font.BOLD, 30));
        sectrem3.setText(String.valueOf(strings[2] + LV20seg[2]));//副词条数值
        sectrem3.setBounds(950, 250 + (2 + 1) * 40, 250, 120);
        this.getContentPane().add(sectrem3);

        JLabel sectrem4 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem4.setForeground(new Color(0, 0, 0));
        sectrem4.setFont(new Font("", Font.BOLD, 30));
        sectrem4.setText(String.valueOf(strings[3] + LV20seg[3]));//副词条数值
        sectrem4.setBounds(950, 250 + (3 + 1) * 40, 250, 120);
        this.getContentPane().add(sectrem4);


        //fwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvye

        //花的副词条
        JLabel sectrem11 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem11.setForeground(new Color(0, 0, 0));
        sectrem11.setFont(new Font("", Font.BOLD, 20));
        sectrem11.setText("副词条" + (0 + 1));
        sectrem11.setBounds(450, (0 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem11);

        JLabel sectrem12 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem12.setForeground(new Color(0, 0, 0));
        sectrem12.setFont(new Font("", Font.BOLD, 20));
        sectrem12.setText("副词条" + (1 + 1));
        sectrem12.setBounds(450, (1 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem12);

        JLabel sectrem13 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem13.setForeground(new Color(0, 0, 0));
        sectrem13.setFont(new Font("", Font.BOLD, 20));
        sectrem13.setText("副词条" + (2 + 1));
        sectrem13.setBounds(450, (2 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem13);

        JLabel sectrem14 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem14.setForeground(new Color(0, 0, 0));
        sectrem14.setFont(new Font("", Font.BOLD, 20));
        sectrem14.setText("副词条" + (3 + 1));
        sectrem14.setBounds(450, (3 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem14);


        //羽的副词条
        JLabel sectrem21 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem21.setForeground(new Color(0, 0, 0));
        sectrem21.setFont(new Font("", Font.BOLD, 20));
        sectrem21.setText("副词条" + (0 + 1));
        sectrem21.setBounds(450, 140 + (0 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem21);

        JLabel sectrem22 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem22.setForeground(new Color(0, 0, 0));
        sectrem22.setFont(new Font("", Font.BOLD, 20));
        sectrem22.setText("副词条" + (1 + 1));
        sectrem22.setBounds(450, 140 + (1 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem22);

        JLabel sectrem23 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem23.setForeground(new Color(0, 0, 0));
        sectrem23.setFont(new Font("", Font.BOLD, 20));
        sectrem23.setText("副词条" + (2 + 1));
        sectrem23.setBounds(450, 140 + (2 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem23);

        JLabel sectrem24 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem24.setForeground(new Color(0, 0, 0));
        sectrem24.setFont(new Font("", Font.BOLD, 20));
        sectrem24.setText("副词条" + (3 + 1));
        sectrem24.setBounds(450, 140 + (3 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem24);


        //沙的副词条
        JLabel sectrem31 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem31.setForeground(new Color(0, 0, 0));
        sectrem31.setFont(new Font("", Font.BOLD, 20));
        sectrem31.setText("副词条" + (0 + 1));
        sectrem31.setBounds(450, 280 + (0 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem31);

        JLabel sectrem32 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem32.setForeground(new Color(0, 0, 0));
        sectrem32.setFont(new Font("", Font.BOLD, 20));
        sectrem32.setText("副词条" + (1 + 1));
        sectrem32.setBounds(450, 280 + (1 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem32);

        JLabel sectrem33 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem33.setForeground(new Color(0, 0, 0));
        sectrem33.setFont(new Font("", Font.BOLD, 20));
        sectrem33.setText("副词条" + (2 + 1));
        sectrem33.setBounds(450, 280 + (2 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem33);

        JLabel sectrem34 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem34.setForeground(new Color(0, 0, 0));
        sectrem34.setFont(new Font("", Font.BOLD, 20));
        sectrem34.setText("副词条" + (3 + 1));
        sectrem34.setBounds(450, 280 + (3 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem34);


        //杯的副词条
        JLabel sectrem41 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem41.setForeground(new Color(0, 0, 0));
        sectrem41.setFont(new Font("", Font.BOLD, 20));
        sectrem41.setText("副词条" + (0 + 1));
        sectrem41.setBounds(450, 420 + (0 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem41);

        JLabel sectrem42 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem42.setForeground(new Color(0, 0, 0));
        sectrem42.setFont(new Font("", Font.BOLD, 20));
        sectrem42.setText("副词条" + (1 + 1));
        sectrem42.setBounds(450, 420 + (1 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem42);

        JLabel sectrem43 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem43.setForeground(new Color(0, 0, 0));
        sectrem43.setFont(new Font("", Font.BOLD, 20));
        sectrem43.setText("副词条" + (2 + 1));
        sectrem43.setBounds(450, 420 + (2 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem43);

        JLabel sectrem44 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem44.setForeground(new Color(0, 0, 0));
        sectrem44.setFont(new Font("", Font.BOLD, 20));
        sectrem44.setText("副词条" + (3 + 1));
        sectrem44.setBounds(450, 420 + (3 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem44);


        //冠的副词条
        JLabel sectrem51 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem51.setForeground(new Color(0, 0, 0));
        sectrem51.setFont(new Font("", Font.BOLD, 20));
        sectrem51.setText("副词条" + (0 + 1));
        sectrem51.setBounds(450, 560 + (0 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem51);

        JLabel sectrem52 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem52.setForeground(new Color(0, 0, 0));
        sectrem52.setFont(new Font("", Font.BOLD, 20));
        sectrem52.setText("副词条" + (1 + 1));
        sectrem52.setBounds(450, 560 + (1 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem52);

        JLabel sectrem53 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem53.setForeground(new Color(0, 0, 0));
        sectrem53.setFont(new Font("", Font.BOLD, 20));
        sectrem53.setText("副词条" + (2 + 1));
        sectrem53.setBounds(450, 560 + (2 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem53);

        JLabel sectrem54 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        sectrem54.setForeground(new Color(0, 0, 0));
        sectrem54.setFont(new Font("", Font.BOLD, 20));
        sectrem54.setText("副词条" + (3 + 1));
        sectrem54.setBounds(450, 560 + (3 + 1) * 20, 200, 120);
        this.getContentPane().add(sectrem54);


        //fwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvyefwixvye

        this.setVisible(true);

        try {
            //ContinuousModification1(firtrem, firtremNUM, sectrem1, sectrem2, sectrem3, sectrem4, sectrem11, sectrem12, sectrem13, sectrem14, sectrem21, sectrem22, sectrem23, sectrem24, sectrem31, sectrem32, sectrem33, sectrem34, sectrem41, sectrem42, sectrem43, sectrem44, sectrem51, sectrem52, sectrem53, sectrem54);
            ContinuousModification2(firtrem, firtremNUM, sectrem1, sectrem2, sectrem3, sectrem4, sectrem11, sectrem12, sectrem13, sectrem14, sectrem21, sectrem22, sectrem23, sectrem24, sectrem31, sectrem32, sectrem33, sectrem34, sectrem41, sectrem42, sectrem43, sectrem44, sectrem51, sectrem52, sectrem53, sectrem54);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }

    private void ContinuousModification1(JLabel firtrem, JLabel firtremNUM, JLabel sectrem1, JLabel sectrem2, JLabel sectrem3, JLabel sectrem4, JLabel sectrem11, JLabel sectrem12, JLabel sectrem13, JLabel sectrem14, JLabel sectrem21, JLabel sectrem22, JLabel sectrem23, JLabel sectrem24, JLabel sectrem31, JLabel sectrem32, JLabel sectrem33, JLabel sectrem34, JLabel sectrem41, JLabel sectrem42, JLabel sectrem43, JLabel sectrem44, JLabel sectrem51, JLabel sectrem52, JLabel sectrem53, JLabel sectrem54) throws InterruptedException {

        //左边花的主词条
        double[] LV20seg1 = {0, 0, 0, 0, 0};
        //左边羽的主词条
        double[] LV20seg2 = {0, 0, 0, 0, 0};
        //左边沙的主词条
        double[] LV20seg3 = {0, 0, 0, 0, 0};
        //左边杯的主词条
        double[] LV20seg4 = {0, 0, 0, 0, 0};
        //左边头的主词条
        double[] LV20seg5 = {0, 0, 0, 0, 0};

        double d11 = 1;//记录暴击率
        double d12 = 1;//记录暴击伤害
        double d21 = 1;//记录暴击率
        double d22 = 1;
        double d31 = 1;//记录暴击率
        double d32 = 1;
        double d41 = 1;//记录暴击率
        double d42 = 1;
        double d51 = 1;//记录暴击率
        double d52 = 1;
        double d;//记录暴击期望值
        double d_before1 = 1;
        double d_before2 = 1;
        double d_before3 = 1;
        double d_before4 = 1;
        double d_before5 = 1;
        int countNUM = 0;

        //计数器
        JLabel count = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        count.setForeground(new Color(0, 0, 0));
        count.setFont(new Font("", Font.BOLD, 20));
        count.setText("刷取圣遗物的次数：0");
        count.setBounds(950, 630, 400, 120);
        this.getContentPane().add(count);

        //A/B套装
        JLabel AB = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        AB.setForeground(new Color(0, 0, 0));
        AB.setFont(new Font("", Font.BOLD, 20));
        AB.setText("A/B套装");
        AB.setBounds(950, 600, 400, 120);
        this.getContentPane().add(AB);

        //花主词条
        JLabel main1 = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        main1.setForeground(new Color(0, 0, 0));
        main1.setFont(new Font("", Font.BOLD, 20));
        main1.setText("生命值4780");
        main1.setBounds(950, 630, 400, 120);
        this.getContentPane().add(main1);

        //速度调节
        /*JLabel speedText = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        speedText.setForeground(new Color(0, 0, 0));
        speedText.setFont(new Font("", Font.BOLD, 20));
        speedText.setText("运行间隔ms");
        speedText.setBounds(820, 683, 400, 120);
        this.getContentPane().add(speedText);
        JTextField speed = new JTextField();
        speed.setBounds(950, 730, 200, 30);
        this.getContentPane().add(speed);*/


        opq:
        while (true) {

            Thread.currentThread().sleep(0);

            countNUM++;
            count.setText("刷取圣遗物的次数：" + countNUM);
            PartGenerator_Method pgm = new PartGenerator_Method();
            int k = pgm.NUMposition();
            String POSITION = pgm.position(k);//部位
            String MAINTERM = pgm.mainTerm(k);//生成主词条
            String[] strings = pgm.FourSecondaryTrem(k, MAINTERM);//生成四个副词条
            double[] seg = pgm.SecondaryEntryGear(k, MAINTERM, strings);//生成4个副词条的数值
            double[] LV20seg = pgm.LV20SecondaryEntryGear(strings, seg);//生成20级副词条数值

            System.out.println(k + " 部位：" + POSITION + " 主词条：" + MAINTERM);

            firtrem.setText(POSITION);
            firtremNUM.setText(MAINTERM);
            sectrem1.setText(strings[0] + LV20seg[0]);
            sectrem2.setText(strings[1] + LV20seg[1]);
            sectrem3.setText(strings[2] + LV20seg[2]);
            sectrem4.setText(strings[3] + LV20seg[3]);

            Random r = new Random();
            int j = r.nextInt(2);
            if (j == 0) {
                AB.setText("是我想要的套装");
                switch (k) {
                    case 1: {
                        //记录暴击率/暴击伤害在数组的哪个位置
                        for (int i = 0; i < 4; i++) {
                            if (Objects.equals(strings[i], "暴击率")) {
                                d11 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "暴击伤害")) {
                                d12 = LV20seg[i];
                            }
                        }
                        d = 2 * d11 + d12;

                        if (d > d_before1) {
                            System.arraycopy(LV20seg, 0, LV20seg1, 0, 4);
                            sectrem11.setText(strings[0] + LV20seg1[0]);
                            sectrem12.setText(strings[1] + LV20seg1[1]);
                            sectrem13.setText(strings[2] + LV20seg1[2]);
                            sectrem14.setText(strings[3] + LV20seg1[3]);
                            d_before1 = d;
                        }
                        if (d > 54) {
                            break opq;
                        }
                        d11 = 1;
                        d12 = 1;

                    }
                    case 2: {
                        //记录暴击率/暴击伤害在数组的哪个位置
                        for (int i = 0; i < 4; i++) {
                            if (Objects.equals(strings[i], "暴击率")) {
                                d21 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "暴击伤害")) {
                                d22 = LV20seg[i];
                            }
                        }
                        d = 2 * d21 + d22;

                        if (d > d_before2) {
                            System.arraycopy(LV20seg, 0, LV20seg2, 0, 4);
                            sectrem21.setText(strings[0] + LV20seg2[0]);
                            sectrem22.setText(strings[1] + LV20seg2[1]);
                            sectrem23.setText(strings[2] + LV20seg2[2]);
                            sectrem24.setText(strings[3] + LV20seg2[3]);
                            d_before2 = d;
                        }
                        if (d > 54) {
                            break opq;
                        }
                        d21 = 1;
                        d22 = 1;
                    }
                    case 3: {
                        if (Objects.equals(MAINTERM, "百分比攻击力")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d31 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d32 = LV20seg[i];
                                }
                            }
                            d = 2 * d31 + d32;

                            if (d > d_before3) {
                                System.arraycopy(LV20seg, 0, LV20seg3, 0, 4);
                                sectrem31.setText(strings[0] + LV20seg3[0]);
                                sectrem32.setText(strings[1] + LV20seg3[1]);
                                sectrem33.setText(strings[2] + LV20seg3[2]);
                                sectrem34.setText(strings[3] + LV20seg3[3]);
                                d_before3 = d;
                            }
                            if (d > 54) {
                                break opq;
                            }
                            d31 = 1;
                            d32 = 1;
                        }
                    }
                    case 4: {
                        if (Objects.equals(MAINTERM, "火元素伤害加成")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d41 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d42 = LV20seg[i];
                                }
                            }
                            d = 2 * d41 + d42;

                            if (d > d_before4) {
                                System.arraycopy(LV20seg, 0, LV20seg4, 0, 4);
                                sectrem41.setText(strings[0] + LV20seg4[0]);
                                sectrem42.setText(strings[1] + LV20seg4[1]);
                                sectrem43.setText(strings[2] + LV20seg4[2]);
                                sectrem44.setText(strings[3] + LV20seg4[3]);
                                d_before4 = d;
                            }
                            if (d > 54) {
                                break opq;
                            }
                            d41 = 1;
                            d42 = 1;
                        }
                    }
                    case 5: {
                        if (Objects.equals(MAINTERM, "暴击率") || Objects.equals(MAINTERM, "暴击伤害")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d51 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d52 = LV20seg[i];
                                }
                            }
                            d = 2 * d51 + d52;

                            if (d > d_before4) {
                                System.arraycopy(LV20seg, 0, LV20seg5, 0, 4);
                                sectrem51.setText(strings[0] + LV20seg5[0]);
                                sectrem52.setText(strings[1] + LV20seg5[1]);
                                sectrem53.setText(strings[2] + LV20seg5[2]);
                                sectrem54.setText(strings[3] + LV20seg5[3]);
                                d_before5 = d;
                            }
                            if (d >= 46) {
                                break opq;
                            }
                            d51 = 1;
                            d52 = 1;
                        }
                    }

                }
            } else {
                AB.setText("不是我想要的套装");
            }


        }
    }

    private void ContinuousModification2(JLabel firtrem, JLabel firtremNUM, JLabel sectrem1, JLabel sectrem2, JLabel sectrem3, JLabel sectrem4, JLabel sectrem11, JLabel sectrem12, JLabel sectrem13, JLabel sectrem14, JLabel sectrem21, JLabel sectrem22, JLabel sectrem23, JLabel sectrem24, JLabel sectrem31, JLabel sectrem32, JLabel sectrem33, JLabel sectrem34, JLabel sectrem41, JLabel sectrem42, JLabel sectrem43, JLabel sectrem44, JLabel sectrem51, JLabel sectrem52, JLabel sectrem53, JLabel sectrem54) throws InterruptedException {

        //左边花的主词条
        double[] LV20seg1 = {0, 0, 0, 0, 0};
        //左边羽的主词条
        double[] LV20seg2 = {0, 0, 0, 0, 0};
        //左边沙的主词条
        double[] LV20seg3 = {0, 0, 0, 0, 0};
        //左边杯的主词条
        double[] LV20seg4 = {0, 0, 0, 0, 0};
        //左边头的主词条
        double[] LV20seg5 = {0, 0, 0, 0, 0};

        double d11 = 1;//记录暴击率
        double d12 = 1;//记录暴击伤害
        double d13 = 1;//记录百分比攻击力
        double d14 = 1;//记录元素精通
        double d15 = 1;//记录充能效率
        double d21 = 1;
        double d22 = 1;
        double d23 = 1;
        double d24 = 1;
        double d25 = 1;
        double d31 = 1;
        double d32 = 1;
        double d33 = 1;
        double d34 = 1;
        double d35 = 1;
        double d41 = 1;
        double d42 = 1;
        double d43 = 1;
        double d44 = 1;
        double d45 = 1;
        double d51 = 1;
        double d52 = 1;
        double d53 = 1;
        double d54 = 1;
        double d55 = 1;
        double d;//记录期望值
        double d_before1 = 1;
        double d_before2 = 1;
        double d_before3 = 1;
        double d_before4 = 1;
        double d_before5 = 1;
        int countNUM = 0;
        long speed = 500;

        //计数器
        JLabel count = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        count.setForeground(new Color(0, 0, 0));
        count.setFont(new Font("", Font.BOLD, 20));
        count.setText("刷取圣遗物的次数：0");
        count.setBounds(950, 630, 400, 120);
        this.getContentPane().add(count);

        //A/B套装
        JLabel AB = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        AB.setForeground(new Color(0, 0, 0));
        AB.setFont(new Font("", Font.BOLD, 20));
        AB.setText("A/B套装");
        AB.setBounds(950, 600, 400, 120);
        this.getContentPane().add(AB);

        //速度调节
        /*JLabel speedText = new JLabel();
        //firtrem.setBorder(new TitledBorder(null,"",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,null,null));
        speedText.setForeground(new Color(0, 0, 0));
        speedText.setFont(new Font("", Font.BOLD, 20));
        speedText.setText("运行间隔ms");
        speedText.setBounds(820, 683, 400, 120);
        this.getContentPane().add(speedText);
        JTextField speed = new JTextField();
        speed.setBounds(950, 730, 200, 30);
        this.getContentPane().add(speed);*/


        Thread.currentThread().sleep(10000);

        opq:
        while (true) {

            if(countNUM==10){
                speed=250;
            }else if (countNUM==50){
                speed=125;
            }else if(countNUM==100){
                speed=60;
            }else if(countNUM==200){
                speed=30;
            }else if(countNUM==500){
                speed=0;
            }

            Thread.currentThread().sleep(speed);

            countNUM++;
            count.setText("刷取单件的次数：" + countNUM);
            PartGenerator_Method pgm = new PartGenerator_Method();
            int k = pgm.NUMposition();
            String POSITION = pgm.position(k);//部位
            String MAINTERM = pgm.mainTerm(k);//生成主词条
            String[] strings = pgm.FourSecondaryTrem(k, MAINTERM);//生成四个副词条
            double[] seg = pgm.SecondaryEntryGear(k, MAINTERM, strings);//生成4个副词条的数值
            double[] LV20seg = pgm.LV20SecondaryEntryGear(strings, seg);//生成20级副词条数值

            System.out.println(k + " 部位：" + POSITION + " 主词条：" + MAINTERM);

            firtrem.setText(POSITION);
            firtremNUM.setText(MAINTERM);
            sectrem1.setText(strings[0] + LV20seg[0]);
            sectrem2.setText(strings[1] + LV20seg[1]);
            sectrem3.setText(strings[2] + LV20seg[2]);
            sectrem4.setText(strings[3] + LV20seg[3]);

            Random r = new Random();
            int j = r.nextInt(2);
            if (j == 0) {
                AB.setText("是我想要的套装");
                switch (k) {
                    case 1: {
                        //记录暴击率/暴击伤害在数组的哪个位置
                        for (int i = 0; i < 4; i++) {
                            if (Objects.equals(strings[i], "暴击率")) {
                                d11 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "暴击伤害")) {
                                d12 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "百分比攻击力")) {
                                d13 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "元素精通")) {
                                d14 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "充能效率")) {
                                d15 = LV20seg[i];
                            }
                        }
                        d = 6 * d11 + 2 * d12 + 2.8 * d13 + 0.5 * d14;

                        if (d > d_before1) {
                            System.arraycopy(LV20seg, 0, LV20seg1, 0, 4);
                            sectrem11.setText(strings[0] + LV20seg1[0]);
                            sectrem12.setText(strings[1] + LV20seg1[1]);
                            sectrem13.setText(strings[2] + LV20seg1[2]);
                            sectrem14.setText(strings[3] + LV20seg1[3]);
                            d_before1 = d;
                        }
                        /*if (d > 54) {
                            break opq;
                        }*/
                        d=1;
                        d11 = 1;
                        d12 = 1;
                        d13 = 1;
                        d14 = 1;
                        d15 = 1;
                        break ;

                    }
                    case 2: {
                        //记录暴击率/暴击伤害在数组的哪个位置
                        for (int i = 0; i < 4; i++) {
                            if (Objects.equals(strings[i], "暴击率")) {
                                d21 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "暴击伤害")) {
                                d22 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "百分比攻击力")) {
                                d23 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "元素精通")) {
                                d24 = LV20seg[i];
                            } else if (Objects.equals(strings[i], "充能效率")) {
                                d25 = LV20seg[i];
                            }
                        }
                        d = 6 * d21 + 2 * d22 + 2.8 * d23 + 0.5 * d24;

                        if (d > d_before2) {
                            System.arraycopy(LV20seg, 0, LV20seg2, 0, 4);
                            sectrem21.setText(strings[0] + LV20seg2[0]);
                            sectrem22.setText(strings[1] + LV20seg2[1]);
                            sectrem23.setText(strings[2] + LV20seg2[2]);
                            sectrem24.setText(strings[3] + LV20seg2[3]);
                            d_before2 = d;
                        }
                        /*if (d > 54) {
                            break opq;
                        }*/
                        d=1;
                        d21 = 1;
                        d22 = 1;
                        d23 = 1;
                        d24 = 1;
                        d25 = 1;
                        break ;
                    }
                    case 3: {
                        if (Objects.equals(MAINTERM, "百分比攻击力")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d31 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d32 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "百分比攻击力")) {
                                    d33 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "元素精通")) {
                                    d34 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "充能效率")) {
                                    d35 = LV20seg[i];
                                }
                            }
                            d = 6 * d31 + 2 * d32 + 2.8 * d33 + 0.5 * d34;
                            if (d > d_before3) {
                                System.arraycopy(LV20seg, 0, LV20seg3, 0, 4);
                                sectrem31.setText(strings[0] + LV20seg3[0]);
                                sectrem32.setText(strings[1] + LV20seg3[1]);
                                sectrem33.setText(strings[2] + LV20seg3[2]);
                                sectrem34.setText(strings[3] + LV20seg3[3]);
                                d_before3 = d;
                            }
                            /*if (d > 54) {
                                break opq;
                            }*/
                            d=1;
                            d31 = 1;
                            d32 = 1;
                            d33 = 1;
                            d34 = 1;
                            d35 = 1;
                            break ;
                        }
                    }
                    case 4: {
                        if (Objects.equals(MAINTERM, "火元素伤害加成")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d41 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d42 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "百分比攻击力")) {
                                    d43 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "元素精通")) {
                                    d44 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "充能效率")) {
                                    d45 = LV20seg[i];
                                }
                            }

                            d = 6 * d41 + 2 * d42 + 2.8 * d43 + 0.5 * d44;

                            if (d > d_before4) {
                                System.arraycopy(LV20seg, 0, LV20seg4, 0, 4);
                                sectrem41.setText(strings[0] + LV20seg4[0]);
                                sectrem42.setText(strings[1] + LV20seg4[1]);
                                sectrem43.setText(strings[2] + LV20seg4[2]);
                                sectrem44.setText(strings[3] + LV20seg4[3]);
                                d_before4 = d;
                            }
                            /*if (d > 54) {
                                break opq;
                            }*/
                            d=1;
                            d41 = 1;
                            d42 = 1;
                            d43 = 1;
                            d44 = 1;
                            d45 = 1;
                            break ;
                        }
                    }
                    case 5: {
                        if (Objects.equals(MAINTERM, "暴击率") || Objects.equals(MAINTERM, "暴击伤害")) {
                            //记录暴击率/暴击伤害在数组的哪个位置
                            for (int i = 0; i < 4; i++) {
                                if (Objects.equals(strings[i], "暴击率")) {
                                    d51 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "暴击伤害")) {
                                    d52 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "百分比攻击力")) {
                                    d53 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "元素精通")) {
                                    d54 = LV20seg[i];
                                } else if (Objects.equals(strings[i], "充能效率")) {
                                    d55 = LV20seg[i];
                                }
                            }
                            d = 6 * d51 + 2 * d52 + 2.8 * d53 + 0.5 * d54;
                            if (d > d_before5) {
                                System.arraycopy(LV20seg, 0, LV20seg5, 0, 4);
                                sectrem51.setText(strings[0] + LV20seg5[0]);
                                sectrem52.setText(strings[1] + LV20seg5[1]);
                                sectrem53.setText(strings[2] + LV20seg5[2]);
                                sectrem54.setText(strings[3] + LV20seg5[3]);
                                d_before5 = d;
                            }
                            /*if (d >= 46) {
                                break opq;
                            }*/
                            d=1;
                            d51 = 1;
                            d52 = 1;
                            d53 = 1;
                            d54 = 1;
                            d55 = 1;
                            break ;
                        }
                    }

                }
            } else {
                AB.setText("不是我想要的套装");
            }



            if (countNUM==100000000){
                break ;
            }
        }
    }

    private void initJmenu() {
        JMenuBar jb = new JMenuBar();
        JMenu jm = new JMenu("功能");
        JMenuItem jm1 = new JMenuItem("A");

        jb.add(jm);
        jm.add(jm1);

        this.setJMenuBar(jb);
    }

    private void initJFrame() {
        this.setSize(1536, 864);
        this.setTitle("FwixvYes完美圣遗物模拟");
        this.setAlwaysOnTop(false);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setLayout(null);

    }

}
